package com.ts.api.module.api.convert.core.annotation;

import com.gitee.apanlh.util.base.ArrayUtils;
import com.gitee.apanlh.util.base.Eq;

/**
 *  下游贷超撞库类型枚举-卖量
 */
public enum ApiConsumerMarketConvertType {

    /** 空 */
    NULL(ConsumerMarketChooseType.NULL, null, "", ""),

    /** ---------------------------------------------------------------------------------- */
    /** MD5模式 */
    DATA_EXCHANGE_MD5(ConsumerMarketChooseType.DATA_EXCHANGE, 0, "consumerMarketMd5Adapter", "consumerMd5:"),
    /** 手机号8位掩码模式 */
    DATA_EXCHANGE_PHONE_MASK_8(ConsumerMarketChooseType.DATA_EXCHANGE,1, "consumerMarketPhoneMask8Adapter", "consumerPhoneMask8:"),
    /** 手机号9位掩码模式 */
    DATA_EXCHANGE_PHONE_MASK_9(ConsumerMarketChooseType.DATA_EXCHANGE,2, "consumerMarketPhoneMask9Adapter", "consumerPhoneMask9:"),
    /** 手机号10位掩码模式 */
    DATA_EXCHANGE_PHONE_MASK_10(ConsumerMarketChooseType.DATA_EXCHANGE,3, "consumerMarketPhoneMask10Adapter", "consumerPhoneMask10:"),
    /** 用户IP撞库模式 */
    DATA_EXCHANGE_IP(ConsumerMarketChooseType.DATA_EXCHANGE,4, "consumerMarketIpAdapter", "consumerIp:"),
    /** 用户表单模式 */
    DATA_EXCHANGE_USER_FORM(ConsumerMarketChooseType.DATA_EXCHANGE,5, "consumerMarketUserFormAdapter", "consumerUserForm:"),


    /** ---------------------------------------------------------------------------------- */
    /** 联登模式-明文手机号 */
    FEDERATE_PHONE(ConsumerMarketChooseType.FEDERATE,0, "consumerMarketFederatePhoneAdapter", "consumerPhoneFederate:"),
    /** 联登模式-全用户资质 */
    FEDERATE_USER_FORM(ConsumerMarketChooseType.FEDERATE,1, "consumerMarketFederateUserFormAdapter", "consumerUserFormFederate:"),
    ;

    /** 选择类型 0撞库 1联登 */
    private ConsumerMarketChooseType chooseType;
    /** 贷超类型值 */
    private Integer type;
    /** 默认对接转换器名称 */
    private String defaultBeanName;
    /** 前缀名称 */
    private String prefixBeanName;

    /**
     * 构造函数
     *
     * @param type
     */
    ApiConsumerMarketConvertType(ConsumerMarketChooseType chooseType, Integer type, String defaultBeanName, String prefixBeanName) {
        this.chooseType = chooseType;
        this.type = type;
        this.defaultBeanName = defaultBeanName;
        this.prefixBeanName = prefixBeanName;
    }

    public ConsumerMarketChooseType getChooseType() {
        return chooseType;
    }

    public Integer getType() {
        return type;
    }

    public String getDefaultBeanName() {
        return defaultBeanName;
    }

    public String getPrefixBeanName() {
        return prefixBeanName;
    }

    public boolean hasType(Integer apiEnvType) {
        return this.getType().equals(apiEnvType);
    }

    /**
     *  根据撞库类型获取枚举
     *
     *  @param  apiDataExchangeType
     *  @return MarketDataExchangeType
     */
    public static ApiConsumerMarketConvertType getDataExchangeEnum(Integer apiDataExchangeType) {
        return ArrayUtils.find(ApiConsumerMarketConvertType.values(), t ->
                Eq.enums(t.getChooseType(), ConsumerMarketChooseType.DATA_EXCHANGE) && t.getType().equals(apiDataExchangeType)
        );
    }

    /**
     *  根据联登类型获取枚举
     *
     *  @param  apiFederateType
     *  @return MarketDataExchangeType
     */
    public static ApiConsumerMarketConvertType getFederateEnum(Integer apiFederateType) {
        return ArrayUtils.find(ApiConsumerMarketConvertType.values(), t ->
                Eq.enums(t.getChooseType(), ConsumerMarketChooseType.FEDERATE) && t.getType().equals(apiFederateType)
        );
    }

    /**
     *  子枚举
     */
    public enum ConsumerMarketChooseType {
        NULL,
        DATA_EXCHANGE,
        FEDERATE,
        ;
    }
}
